#include "app_buffer.h"
#include "log/log.h"

int main(int argc, char const *argv[])
{
    // 初始化
    Buffer *buffer = app_buffer_init(15);
    // 写数据
    app_buffer_write(buffer, "abcd", 5);
    app_buffer_write(buffer, "efgh", 5);
    // 读数据
    char data_buf[100];
    int data_len = app_buffer_read(buffer, data_buf, 100);
    log_debug("data_buf %.*s", data_len, data_buf);

    char data_buf2[100];
    int data_len2 = app_buffer_read(buffer, data_buf2, 100);
    log_debug("data_buf2 %.*s", data_len2, data_buf2);

    char data_buf3[100];
    int data_len3 = app_buffer_read(buffer, data_buf3, 100);
    log_debug("data_buf3 %.*s", data_len3, data_buf3);

    // 写入过长数据会失败
    app_buffer_write(buffer, "13a2s1d654as6546as54sad", 20);
    // 销毁
    app_buffer_free(buffer);
    return 0;
}
